<!--
 * @Author: Dorange.Wang
 * @Date: 2021-04-07 16:19:40
 * @LastEditors: your name
 * @LastEditTime: 2021-04-12 11:26:27
 * @Description: file content
-->
<template>
  <el-dialog :visible="showVisible" center :show-close="false" width="600px">
    <div class="b g3 f16 tl" slot="title">
      <div class="ks-row-between pl15 pr15">
        <span>{{ $t("sys.move_department") }}</span>
        <span
          class="el-icon-close g9 f26 poi"
          @click="showVisible = false"
        ></span>
      </div>
    </div>

    <el-form class="pl30 pr30" :model="formData" ref="form" label-width="120px">
      <el-form-item
        :label="$t('sys.target_department')"
        prop="orgId"
        :rules="[
          { required: true, message: $t('sys.select_target_department'), trigger: 'change' },
        ]"
      >
        <tree-select
          width="400"
          v-model="formData.orgId"
          :treeData="treeData"
        />
      </el-form-item>
    </el-form>

    <div slot="footer" class="tr">
      <el-button @click="showVisible = false">{{$t('sys.cancel')}}</el-button>
      <el-button type="primary" @click="submit">{{$t('sys.confirm')}}</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { putHmuserMoveorg } from '@/apis/paas/HmUserController.js'

export default {
  props: {
    treeData: {
      type: Array,
      default: () => [],
    },
  },

  data() {
    return {
      showVisible: false,
      formData: {},
    };
  },

  computed: {},

  methods: {
    // addForm (record = {}) {
    //   this.showVisible = true
    //   this.formData = { ...record }
    //   this.$nextTick(() => {
    //     this.$refs.form.clearValidate()
    //   })
    // },

    editForm(record) {
      console.log(11111);
      this.formData = { ...record };
      this.showVisible = true;
    },

    async submit() {
      try {
        await this.$refs.form.validate();
        const { ids, srcId, orgId } = this.formData;
        const params = { ids, srcId, orgId };
        const request = putHmuserMoveorg;
        request(params).then((res) => {
          this.showVisible = false;
          this.$emit("ok");
        });
      } catch (error) {
        console.log(error);
      }
    },
  },
};
</script>

<style lang="scss" scoped>
</style>
